﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Data.Objects;
using DataLayer.EntityConfiguration;
using System.Data.SqlClient;

namespace DataLayer
{
    public class DataContext
    {

        public static SampleModel FactoryDataContext()
        {
            String connection = @"Data Source=HVBRRJWKS06\SQLEXPRESS;Initial Catalog=SampleModel;Integrated Security=SSPI;";
            var builder = new ContextBuilder<SampleModel>();
            builder.Configurations.Add(new ContactConfiguration());
            return builder.Create(new SqlConnection(connection));
        }

        public static void CreateDataBase()
        {

            var ctx = FactoryDataContext();
            if (ctx.DatabaseExists())
                ctx.DeleteDatabase();
            ctx.CreateDatabase();

        }

    }
}
